/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package towerdefence.view;

import com.sun.opengl.util.texture.Texture;
import com.sun.opengl.util.texture.TextureIO;
import java.io.IOException;
import java.util.HashMap;
import res.ResourceLoader;

/**
 *
 * @author Andreas
 */
public class TextureHandler {
    
    public static final int BLOCK_STYROFOAM = 0, BLOCK_STEEL = 1, BLOCK_STONE = 2, BUILDER = 3;
    private static HashMap<Integer, Texture> textureMap = new HashMap<Integer, Texture>();
    
    public static Texture getTexture(int texture) {
        return textureMap.get(texture);
    }
    
    protected static void loadTextures() throws IOException {
        loadTexture(BLOCK_STYROFOAM, "styrofoam.png");
        loadTexture(BLOCK_STEEL, "steel.png");
        loadTexture(BLOCK_STEEL, "stone.png");
        loadTexture(BUILDER, "builder.png");
    }

    private static void loadTexture(int texture, String resource) throws IOException {
        textureMap.put(texture, TextureIO.newTexture(ResourceLoader.getResourceURL(resource), true, null));
    }
}
